<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:pe="http://primefaces.org/ui/extensions">
    <h:head>
        <title>#{bundle.savfeatur}</title>
        <link href="./resources/css/default.css" rel="stylesheet" type="text/css" />
    </h:head>
    <h:body>
        <ui:composition>
        <h:form prependId="false">

           <script type="text/javascript">  
                function handleSaveRequest(xhr, status, args) {  
                    if(args.validationFailed || !args.success) {  
                        jQuery('#dialog').effect("shake", { times:3 }, 100);  
                    } else {  
                        dlgSavfeature.hide();  
                    }  
                }
                
                function handleDeleteRequest(xhr, status, args) {  
                    if(args.validationFailed || !args.success) {  
                        jQuery('#dialog').effect("shake", { times:3 }, 100);  
                    } else {  
                        dlgDelSavfeature.hide();  
                    }  
                }
                
                function componenKeyPress(e) {
                    var code = (e.keyCode ? e.keyCode : e.which);
                    if(code==13) {
                       cmdSavfeature.jq.click();
                       e.preventDefault ? e.preventDefault() : e.returnValue = false;
                       e.stopPropagation();
                    }
                }
                
            </script>  

            <!--  -->
            <p:toolbar>
                <p:toolbarGroup align="left">
                    <p:commandButton value="#{bundle.btnNew}"
                                     icon="ui-icon-document"
                                     action="#{savfeatureBean.newData()}"  
                                     rendered="#{menuBean.cekButtonAccess(164,'INS;')}"
                                     oncomplete="dlgSavfeature.show()"
                                     update="displaySavfeature"> 
                    </p:commandButton>

                    <p:commandButton value="#{bundle.btnOpen}" oncomplete="dlgSavfeature.show()"
                                     icon="ui-icon-disk" actionListener="#{savfeatureBean.openData()}"
                                     rendered="#{menuBean.cekButtonAccess(164,'OPN;')}"
                                     update="displaySavfeature" > 
                    </p:commandButton>

                    <p:commandButton type="button" value="#{bundle.btnDelete}" icon="ui-icon-trash"
                                     onclick="dlgDelSavfeature.show()"
                                     update="displaySavfeature" /> 

                    <p:commandButton type="push" value="#{bundle.btnPrint}" icon="ui-icon-print"/>
                </p:toolbarGroup>
            </p:toolbar>
                        
            <p:dataTable var="savfeature" value="#{savfeatureBean.savfeatures}" id="dtSavfeatures"
                         selection="#{savfeatureBean.selectedData}" selectionMode="single" 
                         rowKey="#{savfeature.savfeatureId}" 
                         paginator="true" rows="10" paginatorPosition="bottom" 
                         paginatorTemplate="#{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                         rowsPerPageTemplate="10,15,30">
                
                <p:column style="width:auto" sortBy="#{savfeature.featureName}">
                    <f:facet name="header">#{bundle.globalName}</f:facet>
                    <h:outputText value="#{savfeature.featureName}" />
                </p:column>
            </p:dataTable>
          
            <p:confirmDialog message="#{bundle.confirmDelete}" appendToBody="true" 
                    header="#{bundle.confirmDeleteHeader}" severity="alert" widgetVar="dlgDelSavfeature">  
                <p:commandButton value="#{bundle.btnYes}" update="dtSavfeatures" 
                                 oncomplete="handleDeleteRequest(xhr, status, args)"  
                    actionListener="#{savfeatureBean.delete()}" />  
                <p:commandButton value="#{bundle.btnCancel}" onclick="dlgDelSavfeature.hide()" type="button" />   
            </p:confirmDialog> 

            <p:dialog header="#{bundle.savfeatur}" widgetVar="dlgSavfeature" closable="true"
                      dynamic="true" >
                <p:ajax event="close" listener="#{savfeatureBean.handleClose}"/>
                <h:panelGrid id="displaySavfeature" columns="2" styleClass="addELIT">
                    <h:outputLabel style="padding: 0 15px 0 0" value= "#{bundle.globalName}" />
                    <h:panelGrid columns="2" cellpadding="0" cellspacing="0" rendered="#{savfeatureBean.unsaveData!=null}">
                        <p:inputText value="#{savfeatureBean.unsaveData.featureName}" 
                                 label="#{bundle.globalName}" style="width: 150px;"
                                 required="true" onkeydown="componenKeyPress(event)" id="featrueName1" >
                        <p:ajax update="msgfeatrueName1" process="@this"/>
                        </p:inputText>  
                        <p:message id="msgfeatrueName1" for="featrueName1" display="icon" />
                    </h:panelGrid>  
                </h:panelGrid>
                
                <h:panelGrid columns="2" cellpadding="1" styleClass="pComBtnSTDR">
                    <f:facet name="footer">
                        <p:commandButton value="#{bundle.btnSave}" icon="ui-icon-disk"  actionListener="#{savfeatureBean.save()}"
                                         update="dtSavfeatures" widgetVar="cmdSavfeature"
                            oncomplete="handleSaveRequest(xhr, status, args)"/>
                        <p:commandButton  value="#{bundle.btnClose}" oncomplete="dlgSavfeature.hide()" icon="ui-icon-document" process="@this">
                            <pe:resetEditableValues for="displaySavfeature"/>  
                        </p:commandButton>
                            
                    </f:facet>
                </h:panelGrid>
            </p:dialog> 
        </h:form>
        </ui:composition>    
    </h:body>
</html>
